package org.jeecg.modules.xmss.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.xmss.entity.SysUser;
import org.jeecg.modules.xmss.entity.XmssIdea;
import org.jeecg.modules.xmss.entity.XmssTowns;
import org.jeecg.modules.xmss.vo.AccessTimeVo;

import java.util.List;
import java.util.Map;

/**
 * @Description: 选民意见建议表
 * @Author: jeecg-boot
 * @Date:   2020-09-18
 * @Version: V1.0
 */
public interface XmssIdeaMapper extends BaseMapper<XmssIdea> {
    IPage<XmssIdea> queryPageLists(IPage<XmssIdea> page,
                                                    @Param("name") String name,
                                                    @Param("Time") java.util.Date Time);

    Map<String, String> selectTimeByBan(@Param("accessTimeVo") AccessTimeVo accessTimeVo);

    Map<String, String> selectTimeByNoBan(@Param("accessTimeVo") AccessTimeVo accessTimeVo);

    Map<String, String> selectHourTimeByBan(@Param("accessTimeVo") AccessTimeVo accessTimeVo);

    Map<String, String> selectHourTimeByNoBan(@Param("accessTimeVo") AccessTimeVo accessTimeVo);

    Map<String, String> selectTimeByYes(@Param("accessTimeVo") AccessTimeVo accessTimeVo);

    Map<String, String> selectTimeByNo(@Param("accessTimeVo") AccessTimeVo accessTimeVo);

    Map<String, String> selectTimeByGeneral(@Param("accessTimeVo") AccessTimeVo accessTimeVo);

    Map<String, String> selectByMonth(@Param("accessTimeVo") AccessTimeVo accessTimeVo);


    @Select("select a.* from xmss_idea a left join xmss_supervise b on a.id=b.idea_id where b.user_id=#{userId}  order by create_time desc")
    IPage<XmssIdea> selectIdeaByPersonBig(@Param("page") Page<XmssIdea> page , @Param("userId") String userId);

    @Select("select a.* from xmss_idea a left join xmss_supervise b on a.id=b.idea_id where b.assign_user_id=#{userId}  order by create_time desc")
    IPage<XmssIdea> selectIdeaByPersonJb(@Param("page") Page<XmssIdea> page , @Param("userId") String userId);

    @Select("select * from xmss_towns where id in (select towns_id from xmss_idea where id=#{id})")
    XmssTowns selectAffair(@Param("id") String id);

    @Select("select a.*,b.name ideaTypeName from xmss_idea a left join xmss_idea_type b on a.idea_type=b.id where a.id = #{id} ")
    XmssIdea selectIdeaById(@Param("id") String id);

    @Select("select c.* from xmss_idea a left join xmss_supervise b  on a.id=b.idea_id left join sys_user c on b.user_id = c.id where a.id = #{id} ")
    SysUser selectJbSms(@Param("id") String id);
}
